//
//  CellView.m
//  phmall
//
//  Created by admin on 2017/12/20.
//  Copyright © 2017年 admin. All rights reserved.
//

#import "CellView.h"

@implementation CellView

- (instancetype)init
{
    self = [super init];
    if (self) {
        self.backgroundColor=[UIColor whiteColor];
        
        self.title=[[UILabel alloc]init];
        [self addSubview:self.title];
        self.title.font=[UIFont systemFontOfSize:15];
       
        
        self.leave=[[UIImageView alloc]init];
        self.leave.image=[UIImage imageNamed:@"前往"];
        [self addSubview:self.leave];
       
        
        self.text=[[UITextField alloc]init];
        self.text.textAlignment=NSTextAlignmentRight;
        self.text.textColor=[UIColor colorWithHexString:@"#adadad"];
        self.text.font=[UIFont systemFontOfSize:15];
        [self addSubview:self.text];
        
        
    }
    return self;
}
-(void)layoutSubviews{
    [super layoutSubviews];
    CGSize superSize = self.frame.size;
    
    if (CGSizeEqualToSize(superSize, CGSizeZero)) {
        return;
    }
    [self.title mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.offset(0);
        make.left.offset(10);
    }];
    
    [self.leave mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(-10);
        make.centerY.offset(0);
    }];
    
    CGSize size = [self.title.text sizeWithFont:[UIFont systemFontOfSize:15] constrainedToSize:CGSizeMake(200, MAXFLOAT) lineBreakMode:UILineBreakModeWordWrap];
    [self.text mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.leave.mas_left).offset(-10).priorityHigh();
        make.width.offset(SCREEN_WIDTH-size.width-30-40);
        make.centerY.offset(0);
    }];
}
@end
